#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/opt.h>
#include <libavutil/log.h>
#ifdef __cplusplus
}

#endif

#include <codec.h>


class video_encoder : public ICodec
{
    public:
        video_encoder(/* args */const char* codec_name,AVCodecParameters* codecpar,AVRational timebase);
        ~video_encoder();
        int  decode(AVPacket* pkt,AVFrame* frame,int eof,int& got,int* finished) override;
        int  encode(const AVFrame*  frame, AVPacket* packet,int& got,int* finished) override;
        AVMediaType get_codec_type() const override;
    private:
        AVCodec* m_enc = nullptr;
        bool m_open =false;
        AVCodecContext  *m_enc_ctx = nullptr;
        AVRational m_timebase;
        int64_t m_frame_out_cnt = 0;
        AVCodecParameters* m_codecpar = 0;

};